<!--
 * @Author: CNN 969682281@qq.com
 * @Date: 2023-05-09 16:44:04
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-07-05 14:21:52
 * @FilePath: \newMould_BHZ\src\views\detailedClose.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div id="detailedClose">
    <div class="baseTitle">基本信息</div>
    <div style="height: 230px">
      <publicForm
        ref="publicForm"
        lableWidth="95px"
        :formObj="formObj"
        :formData="formData"
      >
      </publicForm>
    </div>

    <div class="baseTitle">材料用量</div>
    <div
      style="height: 137px; margin-top: 8px"
      class="levelClass materialClass"
    >
      <tableData
        :config="material_config"
        :dataList="materialData"
        statusType="2"
        :level="level"
        :earlyWarning="earlyWarning"
        :currentRow="false"
        :stripe="false"
      />
    </div>

    <div
      class="baseTitle"
      style="margin-top: 8px"
      v-if="
        companyNum == 0 ||
        companyNum == 1 ||
        companyNum == 2 ||
        companyNum == 3 ||
        companyNum == 4 ||
        companyNum == 5
      "
    >
      处理情况
    </div>
    <el-collapse v-model="activeNames" @change="changeCollapse">
      <el-collapse-item
        name="0"
        v-if="
          companyNum == 0 ||
          companyNum == 1 ||
          companyNum == 2 ||
          companyNum == 3 ||
          companyNum == 4 ||
          companyNum == 5
        "
      >
        <template slot="title">
          <div>
            <img
              style="vertical-align: middle"
              src="@/assets/img/Supervision/com_flg.png"
              alt=""
            />
            <span style="margin-left: 8px">闭合申请单</span>
          </div>
        </template>
        <div style="height: 180px; margin-top: 3px">
          <publicForm
            ref="publicForm0"
            lableWidth="95px"
            :formObj="handleObj"
            :formData="handleData"
            :timestamp="handleData.fHandlefile"
            :fileList="fSourcefileList"
          >
          </publicForm>
        </div>
      </el-collapse-item>

      <el-collapse-item
        name="1"
        v-if="
          companyNum == 1 ||
          companyNum == 2 ||
          companyNum == 3 ||
          companyNum == 4 ||
          companyNum == 5
        "
      >
        <template slot="title">
          <div>
            <img
              style="vertical-align: middle"
              src="@/assets/img/Supervision/com_flg.png"
              alt=""
            />
            <span style="margin-left: 8px">一级审核</span>
          </div>
        </template>
        <div style="height: 70px; margin-top: 3px">
          <publicForm
            ref="publicForm1"
            lableWidth="95px"
            :formObj="processObj"
            :formData="handleData"
          >
          </publicForm>
        </div>
      </el-collapse-item>
      <el-collapse-item
        name="2"
        v-if="
          companyNum == 2 ||
          companyNum == 3 ||
          companyNum == 4 ||
          companyNum == 5
        "
      >
        <template slot="title">
          <div>
            <img
              style="vertical-align: middle"
              src="@/assets/img/Supervision/com_flg.png"
              alt=""
            />
            <span style="margin-left: 8px">二级审核</span>
          </div>
        </template>
        <div style="height: 70px; margin-top: 3px">
          <publicForm
            ref="publicForm2"
            lableWidth="95px"
            :formObj="examineObjs"
            :formData="handleData"
          >
          </publicForm>
        </div>
      </el-collapse-item>

      <el-collapse-item
        name="3"
        v-if="companyNum == 3 || companyNum == 4 || companyNum == 5"
      >
        <template slot="title">
          <div>
            <img
              style="vertical-align: middle"
              src="@/assets/img/Supervision/com_flg.png"
              alt=""
            />
            <span style="margin-left: 8px">三级审核</span>
          </div>
        </template>
        <div style="height: 70px; margin-top: 3px">
          <publicForm
            ref="publicForm3"
            lableWidth="95px"
            :formObj="levelThree"
            :formData="handleData"
          >
          </publicForm>
        </div>
      </el-collapse-item>
      <el-collapse-item name="4" v-if="companyNum == 4 || companyNum == 5">
        <template slot="title">
          <div>
            <img
              style="vertical-align: middle"
              src="@/assets/img/Supervision/com_flg.png"
              alt=""
            />
            <span style="margin-left: 8px">四级审核</span>
          </div>
        </template>
        <div style="height: 70px; margin-top: 3px">
          <publicForm
            ref="publicForm4"
            lableWidth="95px"
            :formObj="levelFourth"
            :formData="handleData"
          >
          </publicForm>
        </div>
      </el-collapse-item>
    </el-collapse>
    <div style="height: 50px"></div>
  </div>
</template>

<script>
import publicForm from "@/components/public/Close-form.vue"; //弹框form
import TableData from "@/components/public/el-tables"; //主页面列表
import formJs from "@/views/HntManage/regexDetail.js"; //新增弹框配置项
import {
  getClosedFormByParentId,
  getStationmachineByfMachineid,
} from "@/api/request.js";
export default {
  components: {
    publicForm, //弹框表格
    TableData, //主页面列表
  },
  data() {
    return {
      formObj: formJs.formObj, //新增编辑配置参数
      formData: {}, //新增编辑向后台传递对象
      material_config: formJs.material_config,
      materialData: [], //材料用量列表
      earlyWarning: [], //预警标准
      level: [], //强度等级
      activeNames: ["0"],
      handleData: {
        fCompanyid: "", // 施工标段id
        fId: "", // 申请单fid //为空判断为新增
        fParentid: "", // 对应的超标记录fid
        fWarningcontent: "", // 预警内容
        fReason: "", // 问题原因
        fHandleway: "", // 处理方式
        fHandleresult: "", // 处理结果
        fHandledate: "",
        fHandledates: "", // 处理日期
        fHandleusername: "", // 处理人名称
        fHandlefile: "", // 处理附件id
        fFirstcheckresult: "", // 一级审核处理结果
        fFirstcheckopinion: "", // 一级审核处理意见
        fFirstcheckusername: "", // 一级审核处理人name
        fFirstcheckdates: "", // 一级审核处理日期
        fSecondcheckresult: "", // 二级审核处理结果
        fSecondcheckopinion: "", // 二级审核处理意见
        fSecondcheckusername: "", // 二级审核处理人name
        fSecondcheckdates: "", // 二级审核处理日期
        fThirdcheckresult: "", // 三级审核处理结果
        fThirdcheckopinion: "", // 三级审核处理意见
        fThirdcheckusername: "", // 三级审核处理人name
        fThirdcheckdates: "", // 三级审核处理日期
        fFourthcheckresult: "", // 四级审核处理结果
        fFourthcheckopinion: "", // 四级审核处理意见
        fFourthcheckusername: "", // 四级审核处理人name
        fFourthcheckdates: "", // 四级审核处理日期

        aduitStatus: null, //保存状态
        userId: "", // 当前登录人id
        userName: "", // 当前登录人姓名
        recordfiles: [], // 删除文件id集合
      },
      handleObj: formJs.handleObj, //新增编辑配置参数
      fSourcefileList: [],
      processObj: formJs.processObj, //一级审核
      examineObjs: formJs.examineObj, //二级审核
      levelThree: formJs.levelThree, //三级审核
      levelFourth: formJs.levelFourth, //四级审核
      companyNum: "", //显示隐藏
    };
  },
  created() {},
  mounted() {
    this.getData = {
      fId: window.location.href.split("=")[1].split("&")[0], // 超标记录fid
      fCompanyid: window.location.href.split("=")[2], // 选中的施工标段id
      //   fCompanyid: "a4b6f9f2-ad46-494f-a43c-a1cb2f8e6813",
      //   fId: "38442da6-ba0a-49b1-8227-bb3d63c6d309",
    };
    this.getDetailData(this.getData);
  },
  methods: {
    // 折叠面板
    changeCollapse(e) {
      //   console.log(this.activeNames, e);
      return e;
    },
    getDetailData(data) {
      //没加转圈
      var that = this;
      getClosedFormByParentId(data)
        .then((res) => {
          if (res.errcode == 0) {
            that.getGlName(res.data.dischargeinfo.fMachineid);
            that.formData = res.data.dischargeinfo; //基本信息及材料用量

            if (res.data.dischargeinfo.fWarninglevel == "0") {
              that.formData.fWarninglevel = "正常";
            } else if (res.data.dischargeinfo.fWarninglevel == "1") {
              that.formData.fWarninglevel = "一级";
            } else if (res.data.dischargeinfo.fWarninglevel == "2") {
              that.formData.fWarninglevel = "二级";
            } else if (res.data.dischargeinfo.fWarninglevel == "3") {
              that.formData.fWarninglevel = "三级";
            } else if (res.data.dischargeinfo.fWarninglevel == "4") {
              that.formData.fWarninglevel = "四级";
            } else if (res.data.dischargeinfo.fWarninglevel == "5") {
              that.formData.fWarninglevel = "五级";
            }

            that.fPhotofilelist = res.data.fSourcefileList;
            that.companyNum = that.formData.fCheckstatus;

            var Cement1 = null; //水泥1
            if (
              res.data.dischargeinfo.fCement1actualvalue != "" &&
              res.data.dischargeinfo.fCement1actualvalue != null
            ) {
              Cement1 = res.data.dischargeinfo.fCement1actualvalue - 0;
            } else {
              Cement1 = 0;
            }
            var Cement2 = null; //水泥2
            if (
              res.data.dischargeinfo.fCement2actualvalue != "" &&
              res.data.dischargeinfo.fCement2actualvalue != null
            ) {
              Cement2 = res.data.dischargeinfo.fCement2actualvalue - 0;
            } else {
              Cement2 = 0;
            }
            var Oreactual = null; //矿粉
            if (
              res.data.dischargeinfo.fOreactualvalue != "" &&
              res.data.dischargeinfo.fOreactualvalue != ""
            ) {
              Oreactual = res.data.dischargeinfo.fOreactualvalue - 0;
            } else {
              Oreactual = 0;
            }
            var Flyashactual = null; //粉煤灰
            if (
              res.data.dischargeinfo.fFlyashactualvalue != "" &&
              res.data.dischargeinfo.fFlyashactualvalue != null
            ) {
              Flyashactual = res.data.dischargeinfo.fFlyashactualvalue - 0;
            } else {
              Flyashactual = 0;
            }
            var Admixture1 = null; //外加剂1
            if (
              res.data.dischargeinfo.fAdmixture1actualvalue != "" &&
              res.data.dischargeinfo.fAdmixture1actualvalue != null
            ) {
              Admixture1 = res.data.dischargeinfo.fAdmixture1actualvalue - 0;
            } else {
              Admixture1 = 0;
            }
            var Admixture2 = null; //外加剂2
            if (
              res.data.dischargeinfo.fAdmixture2actualvalue != "" &&
              res.data.dischargeinfo.fAdmixture2actualvalue != null
            ) {
              Admixture2 = res.data.dischargeinfo.fAdmixture2actualvalue - 0;
            } else {
              Admixture2 = 0;
            }
            // 水胶比
            var fWaterbinderratio =
              res.data.dischargeinfo.fWateractualvalue /
              (Cement1 + Cement2 + Oreactual + Flyashactual);
            that.formData.fWaterbinderratio =
              Math.floor(fWaterbinderratio * 100) / 100;

            // 外加剂掺量
            var fAdditiveratio =
              ((Admixture1 + Admixture2) /
                (Cement1 + Cement2 + Oreactual + Flyashactual)) *
              100;
            that.formData.fAdditiveratio =
              Math.floor(fAdditiveratio * 100) / 100;

            this.materialData = [
              {
                name: "设计重量值(kg)",
                show: false,
                water: res.data.dischargeinfo.fWaterdesignvalue,
                cement1: res.data.dischargeinfo.fCement1designvalue,
                cement2: res.data.dischargeinfo.fCement2designvalue,
                aggregate1: res.data.dischargeinfo.fAggregate1designvalue,
                aggregate2: res.data.dischargeinfo.fAggregate2designvalue,
                aggregate3: res.data.dischargeinfo.fAggregate3designvalue,
                aggregate4: res.data.dischargeinfo.fAggregate4designvalue,
                aggregate5: res.data.dischargeinfo.fAggregate5designvalue,
                oredesign: res.data.dischargeinfo.fOredesignvalue,
                flyash: res.data.dischargeinfo.fFlyashdesignvalue,
                admixture1: res.data.dischargeinfo.fAdmixture1designvalue,
                admixture2: res.data.dischargeinfo.fAdmixture2designvalue,
                // cement3: "",
              },
              {
                name: "实际称量值(kg)",
                show: false,
                water: res.data.dischargeinfo.fWateractualvalue, //水
                cement1: res.data.dischargeinfo.fCement1actualvalue, //水泥1
                cement2: res.data.dischargeinfo.fCement2actualvalue, //水泥2
                // cement3: "",
                aggregate1: res.data.dischargeinfo.fAggregate1actualvalue, //骨料1
                aggregate2: res.data.dischargeinfo.fAggregate2actualvalue, //骨料2
                aggregate3: res.data.dischargeinfo.fAggregate3actualvalue, //骨料3
                aggregate4: res.data.dischargeinfo.fAggregate4actualvalue, //骨料4
                aggregate5: res.data.dischargeinfo.fAggregate5actualvalue, //骨料5
                oredesign: res.data.dischargeinfo.fOreactualvalue, //矿粉
                flyash: res.data.dischargeinfo.fFlyashactualvalue, //粉煤灰
                admixture1: res.data.dischargeinfo.fAdmixture1actualvalue, //外加剂1
                admixture2: res.data.dischargeinfo.fAdmixture2actualvalue, //外加剂2
              },
              {
                name: "重量偏差(%)",
                show: false,
                water: res.data.dischargeinfo.fWaterdeviatevalue, //水
                cement1: res.data.dischargeinfo.fCement1deviatevalue, //水泥1
                cement2: res.data.dischargeinfo.fCement2deviatevalue, //水泥2
                aggregate1: res.data.dischargeinfo.fAggregate1deviatevalue, //骨料1
                aggregate2: res.data.dischargeinfo.fAggregate2deviatevalue, //骨料2
                aggregate3: res.data.dischargeinfo.fAggregate3deviatevalue, //骨料3
                aggregate4: res.data.dischargeinfo.fAggregate4deviatevalue, //骨料4
                aggregate5: res.data.dischargeinfo.fAggregate5deviatevalue, //骨料5
                oredesign: res.data.dischargeinfo.fOredeviatevalue, //矿粉
                flyash: res.data.dischargeinfo.fFlyashdeviatevalue, //粉煤灰
                admixture1: res.data.dischargeinfo.fAdmixture1deviatevalue, //外加剂1
                admixture2: res.data.dischargeinfo.fAdmixture2deviatevalue, //外加剂2
              },
              {
                name: "",
                show: true,
                water: res.data.dischargeinfo.fWaterwarninginfo, //水
                cement1: res.data.dischargeinfo.fCement1warninginfo, //水泥1
                cement2: res.data.dischargeinfo.fCement2warninginfo, //水泥2
                aggregate1: res.data.dischargeinfo.fAggregate1warninginfo, //骨料1
                aggregate2: res.data.dischargeinfo.fAggregate2warninginfo, //骨料2
                aggregate3: res.data.dischargeinfo.fAggregate3warninginfo, //骨料3
                aggregate4: res.data.dischargeinfo.fAggregate4warninginfo, //骨料4
                aggregate5: res.data.dischargeinfo.fAggregate5warninginfo, //骨料5
                oredesign: res.data.dischargeinfo.fOrewarninginfo, //矿粉
                flyash: res.data.dischargeinfo.fFlyashwarninginfo, //粉煤灰
                admixture1: res.data.dischargeinfo.fAdmixture1warninginfo, //外加剂1
                admixture2: res.data.dischargeinfo.fAdmixture2warninginfo, //外加剂2
              },
            ];

            this.level = [
              "",
              res.data.dischargeinfo.fWaterwarninglevel,
              res.data.dischargeinfo.fCement1warninglevel,
              res.data.dischargeinfo.fCement2warninglevel,
              res.data.dischargeinfo.fAggregate1warninglevel,
              res.data.dischargeinfo.fAggregate2warninglevel,
              res.data.dischargeinfo.fAggregate3warninglevel,
              res.data.dischargeinfo.fAggregate4warninglevel,
              res.data.dischargeinfo.fAggregate5warninglevel,
              res.data.dischargeinfo.fOrewarninglevel,
              res.data.dischargeinfo.fFlyashwarninglevel,
              res.data.dischargeinfo.fAdmixture1warninglevel,
              res.data.dischargeinfo.fAdmixture2warninglevel,
            ];
            this.earlyWarning = [
              "",
              res.data.dischargeinfo.fWaterwarninginfo,
              res.data.dischargeinfo.fCement1warninginfo,
              res.data.dischargeinfo.fCement2warninginfo,
              res.data.dischargeinfo.fAggregate1warninginfo,
              res.data.dischargeinfo.fAggregate2warninginfo,
              res.data.dischargeinfo.fAggregate3warninginfo,
              res.data.dischargeinfo.fAggregate4warninginfo,
              res.data.dischargeinfo.fAggregate5warninginfo,
              res.data.dischargeinfo.fOrewarninginfo,
              res.data.dischargeinfo.fFlyashwarninginfo,
              res.data.dischargeinfo.fAdmixture1warninginfo,
              res.data.dischargeinfo.fAdmixture2warninginfo,
            ];

            var totalData = res.data.closeinfo; //闭合申请单、一级、二级、三级、四级审核
            this.handleData.fId = totalData.fId; //申请单fid //为空判断为新增
            this.handleData.fCompanyid = totalData.fCompanyid; // 施工标段id
            this.handleData.fWarningcontent = totalData.fWarningcontent; // 预警内容
            this.handleData.fReason = totalData.fReason; // 问题原因

            this.handleData.fHandleresult = totalData.fHandleresult; // 处理结果
            this.handleData.fHandledates = totalData.fHandledates; //处理日期
            this.handleData.fHandleusername = totalData.fHandleusername; // 处理人名称
            this.fSourcefileList = res.data.fSourcefileList; // 附件
            this.handleData.fHandlefile = totalData.fHandlefile; //处理附件id
            this.handleData.fHandleway = totalData.fHandleway; // 处理方式

            this.handleData.fFirstcheckresult = totalData.fFirstcheckresult; // 一级审核处理结果
            this.handleData.fFirstcheckopinion = totalData.fFirstcheckopinion; // 一级审核处理意见
            this.handleData.fFirstcheckusername = totalData.fFirstcheckusername; //一级审核处理人name
            this.handleData.fFirstcheckdates = totalData.fFirstcheckdates; //一级审核处理日期

            this.handleData.fSecondcheckresult = totalData.fSecondcheckresult; // 二级审核处理结果
            this.handleData.fSecondcheckopinion = totalData.fSecondcheckopinion; // 二级审核处理意见
            this.handleData.fSecondcheckusername =
              totalData.fSecondcheckusername; //二级审核处理人name
            this.handleData.fSecondcheckdates = totalData.fSecondcheckdates; //二级审核处理日期

            this.handleData.fThirdcheckresult = totalData.fThirdcheckresult; // 三级审核处理结果
            this.handleData.fThirdcheckopinion = totalData.fThirdcheckopinion; // 三级审核处理意见
            this.handleData.fThirdcheckusername = totalData.fThirdcheckusername; //三级审核处理人name
            this.handleData.fThirdcheckdates = totalData.fThirdcheckdates; //二级审核处理日期

            this.handleData.fFourthcheckresult = totalData.fFourthcheckresult; // 四级审核处理结果
            this.handleData.fFourthcheckopinion = totalData.fFourthcheckopinion; // 四级审核处理意见
            this.handleData.fFourthcheckusername =
              totalData.fFourthcheckusername; //四级审核处理人name
            this.handleData.fFourthcheckdates = totalData.fFourthcheckdates; //四级审核处理日期
          } else {
            this.$toast.fail(res.msg);
            return false;
          }
        })
        .catch((error) => {
          this.$toast.fail(error.msg);
          return false;
        });
    },
    getGlName(data) {
      getStationmachineByfMachineid({ machineId: data })
        .then((res) => {
          if (res.errcode == 0) {
            this.material_config.thead[4].label =
              res.data.yjQmpMsStationmachine.fParm1;
            this.material_config.thead[5].label =
              res.data.yjQmpMsStationmachine.fParm2;
            this.material_config.thead[6].label =
              res.data.yjQmpMsStationmachine.fParm3;
            this.material_config.thead[7].label =
              res.data.yjQmpMsStationmachine.fParm4;
            this.material_config.thead[8].label =
              res.data.yjQmpMsStationmachine.fParm5;
          } else {
            this.$message.error("获取骨料名", res.msg);
          }
        })
        .catch((error) => {
          console.log("获取骨料名接口报错", error.msg);
        });
    },
  },
};
</script>

<style scoped lang="less">
#detailedClose {
  font-family: inherit;
  padding: 0 10px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  /* background: hotpink; */
  .baseTitle {
    border-bottom: 1px solid #0c204d;
    height: 30px;
    line-height: 30px;
    position: relative;
    padding-left: 15px;
    color: #606266;
    font-size: 14px;
    word-break: break-all;
  }

  .baseTitle::after {
    display: block;
    content: "";
    height: 30px;
    width: 5px;
    position: absolute;
    left: 0;
    top: 0;
    background: #0c204d;
  }
  /deep/ .el-form-item__content {
    line-height: 30px;
  }
  /deep/ .el-form-item__label {
    line-height: 30px;
  }
  /deep/ .el-input.is-disabled .el-input__inner {
    background: aliceblue;
    font-size: 12px;
    color: #676d77;
  }
  /deep/.el-table tr:nth-child(4) {
    display: none;
  }
}
</style>